package com.jerry.controller;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by Shirly on 2016/9/2.
 */
public class getSpringBean {
    protected static ApplicationContext appContext;
    static {
        try {
            long start = System.currentTimeMillis();
            System.out.println("正在加载配置文件...");
            appContext = new ClassPathXmlApplicationContext(new String[]{"classpath:mvc-dispatcher-servlet.xml"});
            System.out.println("配置文件加载完毕,耗时：" + (System.currentTimeMillis() - start));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        getSpringBean.appContext.getAutowireCapableBeanFactory().autowireBeanProperties(appContext, DefaultListableBeanFactory.AUTOWIRE_BY_NAME, false);
        System.out.println(appContext.getBeanDefinitionNames().getClass());
    }

}
